home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / VXAVTOOL.ZIP / MISC-VIR.ZIP / TED10.ZIP / TED.ASM next >
Encoding:
Assembly Source File  |  1992-01-21  |  4.2 KB  |  152 lines

  1. ;
  2. ; TED v1.0
  3. ; (Text Encryption Device)
  4. ;
  5. ; Written by Data Disruptor
  6. ; (c) 1991 The RABID International Development Corp.
  7. ;
  8.  
  9. @print  macro   string
  10.         mov     ah,09h
  11.         mov     dx,offset string
  12.         int     21h
  13. endm
  14.  
  15.     dosseg
  16.     .model small
  17.     .stack 100h
  18.     .data
  19.  
  20. ident   db   13,10
  21.         db   "Text Encryption Device (TED) v1.0",13,10
  22.         db   "Written by Data Disruptor (Aug.16.91)",13,10,13,10
  23.         db   "(c) 1991 The RABID International Development Corp.",13,10,13,10
  24.         db   "Please enter text now",13,10
  25.         db   ">$"
  26.  
  27.  
  28.  
  29. open_er db      "Error opening file",13,10,"$"
  30.  
  31. writ_er db      "Error writing data",13,10,"$"
  32.  
  33. clos_er db      "Error closing file",13,10,"$"
  34.  
  35. saved   db      "Encrypted text saved in ENCRYPT.TXT",13,10,"$"
  36.  
  37. input   db      80 dup (?)                      ; Set input buffer
  38.  
  39. dest    db      80 dup (?)            ; Set a blank field to be
  40.                         ; the destination point for
  41.                         ; the encrypted string
  42. temp    db    0                ; Tσmporary encrypted 
  43.                         ; charachter buffer
  44. dol    db    "$",13,10                       ; EOL so that we don't get
  45.                                 ; a whole lot of crap on
  46.                                                 ; the screen
  47. crlf    db      13,10,"$"
  48.  
  49. counter db      0                               ; For # of keypresses
  50.  
  51. file    db      "encrypt.txt",0
  52. filehndl dw     0                               ; Save the file handle
  53.  
  54.     .code
  55.  
  56. start:    mov    ax,@data            ; Read @DS into AX
  57.     mov    ds,ax                ; Copy AX into DS
  58.  
  59.         @print  ident
  60.  
  61.         mov     si,offset input
  62.         mov     cx,1
  63. keyp:
  64.         mov     ah,01h                          ; Get keypress
  65.         int     21h
  66.         cmp     al,13                           ; Is it a CR?
  67.         je      exit_key                        ; Yes? Quit
  68.         cmp     al,8
  69.         je      dec_si
  70.         mov     [si],al                         ; No? Store the keypress
  71.         inc     cx
  72.         inc     si
  73.         jmp     keyp
  74.  
  75. dec_si: dec     si
  76.         jmp     keyp
  77.  
  78. exit_key:
  79.         @print  crlf
  80.     mov    si,offset input            ; Copy string into SI
  81.     mov    di,offset dest            ; Copy target into DI
  82. encrypt:mov    al,ds:[si]            ; Copy first charachter
  83.                         ; in SI into AL
  84.     mov    temp,al                ; Copy AL into TEMP
  85.     xor    byte ptr ds:[temp],1ah        ; Encrypt TEMP with byte 01h
  86.     mov    al,temp                ; Copy TEMP back into AL
  87.     mov    [di],al                ; Move AL into DI
  88.     inc    si                ; Increase counter [SI]
  89.     inc    di                ; Increase counter [DI]
  90.     loop    encrypt                ; Get the next byte in the
  91.                         ; string
  92.     mov    dx,offset dest            ; copy encrypted string into DX
  93.     call    print                ; INT 21h, func 09h
  94.     jmp    quit                ; Quit the program
  95.  
  96. print:    mov    ah,09h                ; Procedure to output stσing
  97.     int    21h                ; in DX to the screen
  98.     ret                    ; Return to where we were
  99.                         ; called from
  100.  
  101. quit:   mov    dx,offset dol
  102.     call    print
  103.         mov     ah,3ch                          ; Create a file
  104.         xor     cx,cx                           ; Normal attributes
  105.         mov     dx,offset file                  ; Set the name of the file
  106.         int     21h
  107.         jc      open_error
  108.  
  109.         mov     word ptr [filehndl],ax          ; Save the file handle
  110.  
  111.         mov     ah,40h
  112.         mov     bx,word ptr [filehndl]
  113.         mov     cx,80
  114.         mov     dx,offset input
  115.         int     21h
  116.  
  117.         mov     ah,40h                          ; Write to file
  118.         mov     bx,word ptr [filehndl]          ; Set file handle in BX
  119.         mov     cx,80
  120.         mov     dx,offset dest                  ; Set for text buffer
  121.         int     21h
  122.  
  123.         jc      write_error
  124.  
  125.         mov     ah,3eh                          ; Close the file
  126.         mov     bx,word ptr [filehndl]          ; ...in the file handle...
  127.         int     21h
  128.  
  129.         jc      close_error
  130.  
  131.         @print  saved
  132.         jmp     bye
  133.  
  134. open_error:
  135.         @print  open_er
  136.         jmp     error
  137. write_error:
  138.         @print  writ_er
  139.         jmp     error
  140. close_error:
  141.         @print  clos_er
  142.         jmp     error
  143.  
  144. error:  mov     ah,0eh
  145.         mov     al,07                           ; Beep!
  146.         int     10h
  147.  
  148. bye:
  149.     mov    ax,4c00h            ; Terminate program with
  150.     int    21h                ; exit code 00
  151. end    start                        ; Gedoudahere!
  152.